package pl.taskman.testing;

import java.awt.Color;

import info.clearthought.layout.TableLayout;

import javax.swing.*;

public class LoginViewPanel extends CustomPanelTest {

	/**
	 * Generated serial ID 
	 */
	private static final long	serialVersionUID = -4666607504385367274L;
	
	private CustomButton 		button_login 		= null;
	private CustomButton 		button_cancel 		= null;
	private CustomButton 		button_addUser 		= null;
	private CustomButton 		button_removeUser	= null;
	private JCheckBox 			cb 					= null;
	private JComboBox 			usersDropList 		= null;
	private JPasswordField 		pwField 			= null;
	private JLabel 				label_login 		= null;
	private JLabel 				label_password 		= null;
	
	// TO_BE_REMOVED ##############################
	private String[] users = {"NiTh", "m4rt"};
	// ############################################

	public LoginViewPanel (Color color)
	{
		super(color);
		initComponents(); 
        localInitialization();
	}

	private void localInitialization() {
		// TODO Auto-generated method stub
		
	}

	private void initComponents() 
	{	
		button_cancel = new CustomButton();
		button_login = new CustomButton();
		button_addUser = new CustomButton();
		button_removeUser = new CustomButton();
		cb = new JCheckBox();
		usersDropList = new JComboBox();
		pwField = new JPasswordField();
		label_login = new JLabel("Login:");
		label_password = new JLabel("Password:");
		
		//initializing exit button
		{
			button_cancel.setText("Exit");
			button_cancel.addActionListener(Manager.getActionListener());
			button_cancel.setActionCommand("QUIT");
		}
		
		//initializing login button
		{
			button_login.setText("Log in");
			button_login.addActionListener(Manager.getActionListener());
			button_login.setActionCommand("LOG_IN");
		}
		
		//initializing add-user button
		{
			button_addUser.setText("+");
			button_addUser.addActionListener(Manager.getActionListener());
			button_addUser.setActionCommand("ADD_USER");
		}
		
		//initializing remove-user button
		{
			button_removeUser.setText("-");
			button_removeUser.addActionListener(Manager.getActionListener());
			button_removeUser.setActionCommand("REMOVE_USER");
		}
		
		//initializing 'remember me' checkbox
		{
			cb.addActionListener(Manager.getActionListener());
			cb.setActionCommand("REMEMBER_ME");
		}
		
		
		
		//initializing users dropdown list
		{
			//TODO: integrate with rego's integration controller
			for (int i=0;i<users.length;i++) usersDropList.addItem(users[i]);
			//usersDropList.addActionListener(Manager.getActionListener());	
		}
		
		
		{
			double size[][] =
			{ { 0.1, 0.2, 0.05, 0.2, 0.05, 0.05, 0.2, 0.05, 0.1 },
			{ TableLayout.FILL, 0.1, 0.05, 0.1, 0.1, 0.1, TableLayout.FILL } };
			setLayout(new TableLayout(size));
			add(label_login, "1,1");
			add(button_addUser, "2,1");
			add(usersDropList, "3,1 , 6,1");
			add(button_removeUser, "7,1");
			
			add(label_password, "1,3");
			add(pwField, "2,3 , 7,3");
			
			add(button_login, "3,5");
			add(button_cancel, "6,5");
			
		}
	}
	
}
